#include <stdio.h>
#include <string.h>
#include <math.h>

int zero(double x)
{
	if (fabs(x)<1e-8) return 1;
	return 0;
}

main()
{

	double w1,w2,t1,t2,dt, wb;	
	double k, tot1, tot2, rest, tt, rong, w12;


	while (1)
	{
		scanf("%lf%lf%lf%lf", &w1, &w2, &t1, &t2);
		if (zero(w1) && zero(w2) && zero(t1) && zero(t2)) break;
		t2=-t2;
		w12=w1+w2;
		tot1=w1*t1*4.19;
		tot2=w2*t2*2.09+335*w2;
		if (tot1>tot2)
		{
			rest=tot1-tot2;
			tt=rest/(w12)/4.19;
			printf("0.0 g of ice and %.1lf g of water at %.1lf C\n",w12,tt);			
			
		}
		else
		{
			rest=tot2-tot1;
			rong=(w12)*335;
			if (rest>=rong)
			{
				rest-=rong;
				tt=rest/(w12)/2.09;
				tt=-tt;
				printf("%.1lf g of ice and 0.0 g of water at %.1lf C\n",w12,tt);					
			}
			else
			{
				wb=rest/335;
				printf("%.1lf g of ice and %.1lf g of water at 0.0 C\n", wb,w12-wb);
					
					

			}
		}

//		printf("%lf\n", tt);

		


	
		
	}
	return 0;

}
